import load
import pre

def get17Avg(group):
    allChannel = []
    for _ in range(40):  # 从1到39，为了下标对应，0不要了
        allChannel.append(pre.newChannel())

    startSub = load.getT1StartSub(group)

    for i in range(195):
        comNum = int(load.getCellT1(i, startSub + load.comNum))
        year = int(load.getCellT1(i, startSub + load.year))
        if year == 2017:  # 只计算17
            for d in range(8):
                sum, num = allChannel[comNum][d]
                tableD = d + load.d1
                sum += float(load.getCellT1(i, startSub + tableD))
                num += 1
                allChannel[comNum][d] = [sum, num]

    for comNum in range(1, 40):
        for d in range(8):
            sum, num = allChannel[comNum][d]
            allChannel[comNum][d] = sum / num

    return allChannel

for g in range(1,7):
    allChannel=get17Avg(g)
    print(pre.strAllChannel(allChannel))